﻿using Microsoft.Extensions.Logging;
using NetLogExtend.Model;
using NetLogExtend.MSLogging.Abstractions;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using static System.Collections.Specialized.BitVector32;

namespace NetLogExtend.Extensions
{

//    /// <summary>
//    /// 日志扩展
//    /// </summary>
//    public static partial class Extensions
//    {
///// <summary>
///// 注册NLog日志操作
///// </summary>
///// <param name="services">服务集合</param>
//        public static void AddNLog(this IServiceCollection services)
//        {
//            services.TryAddScoped<ISession, Session>();
//services.TryAddScoped<ILogProviderFactory, Logs.NLog.NLogProviderFactory>();
//            services.TryAddSingleton<ILogFormat, ContentFormat>();
//            services.TryAddScoped<ILogContext, LogContext>();
//            services.TryAddScoped<Common.Logs.ILog, Log>();
//        }

//        /// <summary>
//        /// 注册Log4net日志操作
//        /// </summary>
//        /// <param name="services">服务集合</param>
//        /// <param name="log4NetConfigFile">log4net配置文件路径</param>
//        public static void AddLog4net(this IServiceCollection services, string log4NetConfigFile = "log4net.config")
//        {
//            var fileNamePath = log4NetConfigFile;
//            if (!Path.IsPathRooted(fileNamePath))
//            {
//                if (!File.Exists(fileNamePath))
//                {
//                    fileNamePath = Path.Combine(Path.GetDirectoryName(Assembly.GetEntryAssembly().Location), fileNamePath);
//                }
//            }
//            fileNamePath = Path.GetFullPath(fileNamePath);

//            var repository = LogManager.CreateRepository(Log4Provider.LOG_REPOSITORY_NAME);
//            log4net.Config.XmlConfigurator.ConfigureAndWatch(repository, new FileInfo(fileNamePath));

//            services.TryAddScoped<ISession, Session>();
//services.TryAddScoped<ILogProviderFactory, Log4ProviderFactory>();
//            services.TryAddSingleton<ILogFormat, ContentFormat>();
//            services.TryAddScoped<ILogContext, LogContext>();
//            services.TryAddScoped<Common.Logs.ILog, Log>();

//            services.AddSingleton<ILoggerProvider>(new Log4Provider("", new ContentFormat()));
//        }

//        /// <summary>
//        /// Adds the ms log.
//        /// </summary>
//        /// <param name="serviceProvider">The service provider.</param>
//        public static void AddMSLog(this IServiceProvider serviceProvider)
//        {
//            serviceProvider.GetService<ILoggerFactory>().AddProvider(new Logs.MSLogging.LoggerProvider());
//        }

//        /// <summary>
//        /// 注册Exceptionless日志操作
//        /// </summary>
//        /// <param name="services">服务集合</param>
//        /// <param name="configAction">配置操作</param>
//        public static void AddExceptionless(this IServiceCollection services, Action<ExceptionlessConfiguration> configAction)
//        {
//            services.TryAddScoped<ILogProviderFactory, Logs.Exceptionless.LogProviderFactory>();
//            services.TryAddSingleton(typeof(ILogFormat), t => NullLogFormat.Instance);
//            services.TryAddScoped<ILogContext, Logs.Exceptionless.LogContext>();
//            services.TryAddScoped<Common.Logs.ILog, Log>();
//            configAction?.Invoke(ExceptionlessClient.Default.Configuration);
//        }
//    }

}
